class ValueList:
    def row_of(self, index):
        # for i in range(len(self.row_list)):
            # if index < (i + 1)*len(self.column_list):
                # return i
        return int(index/len(self.column_list))
        
    def column_of(self, index):
        # temp = index
        # quantum = len(self.column_list)
        # while temp > quantum:
            # temp -= quantum
        # return temp
        return index%len(self.column_list)
            
    def add_row(self, index, value):
        target = self.row_list[self.row_of(index)]
        if not value in target:
            target.append(value)
            
    def add_column(self, index, value):
        target = self.column_list[self.column_of(index)]
        if not value in target:
            target.append(value)
            
    def add(self, index, value):
        self.add_row(index, value)
        self.add_column(index, value)
        
    def remove_row(self, index, value):
        target = self.row_list[self.row_of(index)]
        if value in target:
            target.remove(value)
            return True
        return False
        
    def remove_column(self, index, value):
        target = self.column_list[self.column_of(index)]
        if value in target:
            target.remove(value)
            return True
        return False
            
    def remove(self, index, value):
        self.remove_row(index, value)
        self.remove_column(index, value)